<?php
include_once("../smiley.php");
include_once("../includes/common_snippets.php");
/**
 * @author gencyolcu
 * @copyright 2014
 */

$relpath=getScriptLocatedAbsolutePath();

function manageCommentsUpload($mediaUploads,$downloadPrivacyType){
    $feedSection="";
    if(is_array($mediaUploads) && count($mediaUploads)>0){
      //  print_r($mediaUploads);
    //die();
        $videocount=0;
        
        foreach($mediaUploads as $mediaUpload){
            $currentId=$mediaUpload["Comment_ID"];
            
            if($mediaUpload["Media_Type"]=="IMAGE")
            {
                $fpathencoded=urlencode($mediaUpload["Media_Path"]);
                $feedSection.='<a href="'.$mediaUpload["Media_Path"].'" data-lightbox="roadtrip'.$currentId.'" style="float:left;padding: 2px;">
                                <img src="'.$mediaUpload["Media_Path"].'" width="150px">';
                if($downloadPrivacyType==1){                
                    $feedSection.='<div><a style="float:right;margin-right:25px" href="downloadpics.php?filepathdownload='.$fpathencoded.'">Download !!</a></div>
                                </a>';
                }
            }
            else
            {
                $feedSection.='
                <div id="videouploaded_'.$currentId.'_'.$videocount.'" style="width:500px;height:350px;"></div>
                    <script type="text/javascript">
                        jwplayer("videouploaded_'.$currentId.'_'.$videocount.'").setup({
                            "flashplayer": "js/jwplayer.flash.swf",
                            "file": "'.$mediaUpload["Media_Path"].'",
                            "image": "images/dummy_video.jpg",
                            "controlbar": "bottom",
                            "width": "500",
                            "height": "350"
                        });
                    </script>
                </div>    
                ';
                $videocount++;
            }
            $feedSection.='';
        }
    }
    return $feedSection;
}
function generateScript($uploadPostId){
    return '<script type="text/javascript">
             
            $(function() {
			    var btnUpload =$("#cmnt_img-'.$uploadPostId.'");
			    new AjaxUpload(btnUpload, {
			        action: \'uploadImage.php?cmpid='.$uploadPostId.'&action_str=commentimage\',
			        name: \'uploadcmntfile\',
			        onSubmit: function(file, ext) {
			
                        if (!(ext && /^(jpg|png|jpeg|gif)$/.test(ext))) {
                            // extension is not allowed 
                            alert(\'Only JPG, PNG or GIF files are allowed\');
                            return false;
                        }
			            //newly added
			            fileuploadrequest_c++;
			            var uploadFileCounter = "uploadc-" + fileuploadrequest_c;
			            var UploadingList = "<div id=\'" + uploadFileCounter + "\'>" + file + "</div>";
			
			            this.setData({ X_UPLOADER: uploadFileCounter,X_ID:'.$uploadPostId.' });
			            //add row for processing
			            var fsize = "   -";
			            //alert(file);
			            addUploadProcessingRow('.$uploadPostId.', uploadFileCounter, file);
			            //alert("on submit");
			        },
			        onComplete: function(file, response) {
			        	
			            var responseForFile = response;
			            var responseTextArr = responseForFile.split("$");
			            var responseTextVal = responseTextArr[1];
			            var responseForFile = responseTextArr[0];
			            var responseTextSize = responseTextArr[2];
			
			            var requestedFileResponseForFile = "uploadc-" + responseForFile;
			
			            //add response from server to file progress
			            setResponseOnUploadProgress(response);
			        }
			     });
              });
            </script>';
             
}

function addCommentUploadSection($currentPostId){
    return '<div class="commentbottom">
                <div style="width:30px;height:20px;float:left;" >
                    <span id="cmnt_img-'.$currentPostId.'" class="upcmntfile">UP</span>
                    <div style="display:none">                              
                        <input type="hidden" name="commentmediauploadpath" id="commentmediauploadpath" value=""/>
                        '.generateScript($currentPostId).'
                    </div>
                </div>
                <br/><br/>
                <div>
                    <ul id="cmntupload_filelist" class="plupload_filelist"></ul>
                </div>
            </div>';
}

function getTaggedUserDetails($taggedUsersList){
    $usersJson="";
    $friendReqJSON[]= new DetailJson();
    $oNotification= new Notifications();
    $UserDetail=array();
    $friendsCount=0;
    for($uCount=0;$uCount<count($taggedUsersList);$uCount++){
        $UserDetail=$oNotification->getUserDetails($taggedUsersList[$uCount]);
        $friendReqJSON[$friendsCount]->actionByUserId=$UserDetail["uid"];
        $friendReqJSON[$friendsCount]->actionByUserName=$UserDetail["uname"];
        $friendReqJSON[$friendsCount]->actionByUserProfilePicpath=$UserDetail["picpath"];
        $friendReqJSON[$friendsCount]->actionByUserLink=$UserDetail["plink"];
        $friendReqJSON[$friendsCount]->actionByUserIsCelibrity=$UserDetail["Is_Celebrity"];
        $friendsCount++;
    }
    $usersJson= $oNotification->getUserDetailsJSON($friendReqJSON);
    return $usersJson;
}
function getNewsFeedLeft($feedID,$newsFeeds){
    global $relpath;
    //echo "<pre>";
    //    print_r($newsFeeds);
    //echo "</pre>";
    $loggedUserObjlocal=new UserDetails();
    $loggedUserObjlocal->getUserDetails($_SESSION["Allyfolio_User_ID"],true);
    $postUserDetail=new UserDetails();
    $commentUserDetail= new UserDetails();
    $postUserDetail->getUserDetails($newsFeeds["User_ID"]);
    //echo "<pre>";
//    print_r($postUserDetail);
//    echo "</pre>";
    $likesharepost="";
    $postFeeds= new ReadFeedAction();
    $postComments= array();
    $postUploads=array();
    $taggedUsersList=array();
    $taggingMsgWithPost="";
    
    
    
    if($newsFeeds["Post_ID"]!=null && is_numeric(trim($newsFeeds["Post_ID"])) && trim($newsFeeds["Post_ID"])>0){
        $postComments=$postFeeds->ReadPostComments($newsFeeds["Post_ID"]);        
        $postUploads= $postFeeds->ReadPostUploads($newsFeeds["Post_ID"]);
        //echo "<pre>";
        //print_r($postUploads);
        //echo "</pre>";
        //$postUploads=(isset($postUploads[0]))?$postUploads[0]:array();
        //reported abused
        $oDropfilters= new CGetFilters();
        $postReportAbused=array();
        $postReportAbused=$oDropfilters->getPostReportAbuseTypes($_SESSION["Allyfolio_User_ID"],$newsFeeds["Post_ID"]);
        
        if(is_array($postReportAbused) && count($postReportAbused)>0){
            $postReportAbused=$postReportAbused[0];
        }
        //print_r($postReportAbused);    
        $isReportedAbusedOrHidden=false;
        if(is_array($postReportAbused) && isset($postReportAbused["Report_Abuse_IDs"]) && isset($postReportAbused["Status"]) && isset($postReportAbused["Is_Approved_By_Admin"]) ){
            //if report abused and is approved by admin then treat it as approved reported abused
            if($postReportAbused["Is_Approved_By_Admin"]==1 && (strstr($postReportAbused["Report_Abuse_IDs"],",") || is_numeric($postReportAbused["Report_Abuse_IDs"]))){
                $isReportedAbusedOrHidden=true;    
            }
            //or if not approved as reported abused then check if post is hidden (0)
            if($postReportAbused["Status"]==0){
                $isReportedAbusedOrHidden=true;
            }
        }
        if($isReportedAbusedOrHidden)
            return;
            
    }
    
    if($newsFeeds["Friend_IDs"]!=""){
        if(strstr($newsFeeds["Friend_IDs"],",")){
            $taggedUsersList=explode(",",$newsFeeds["Friend_IDs"]);
        }
        else{
            $taggedUsersList[0]=$newsFeeds["Friend_IDs"];
        }
    }
    
    $emotionstext="";
    if($newsFeeds["postedemotion"]!="" && strlen($newsFeeds["postedemotion"])>0){
        $newsFeeds["postedemotion"]=getSmileyDataForSave($newsFeeds["postedemotion"]);
        $emotionstext="<span class='feel-em'> ".$newsFeeds["postedemotion"]."</span>";
    }
    
    if(is_array($taggedUsersList) && count($taggedUsersList)){
        $taggingMsgWithPost=' was with {3} <a onclick="showTaggedPersons(\'ptaguser\');"> {1} {2} </a>';
        $inputHidden="<input type='hidden' id='ptaguser' name='ptaguser' value='{1}'/>";
            
        $taggedUsersJson=getTaggedUserDetails($taggedUsersList);
        $oNotification= new Notifications();
        $inputHidden=$oNotification->str_format($inputHidden,$taggedUsersJson);
        $taggingMsgWithPost=$oNotification->str_format($taggingMsgWithPost,count($taggedUsersList),(count($taggedUsersList)>1)?"peoples":"people",$inputHidden);
        //$taggingMsgWithPost=str_format($taggingMsgWithPost,count($taggedUsersList),(count($taggedUsersList)>1)?"peoples":"people",$taggedUsersJson);
    }
    //echo "<pre>user postUploads <br>";
//    print_r($postUploads);
//    echo "</pre>";
    
    if($postUserDetail->isCelibrity==true){
       $likesharepost='<!--like/post--> <p onclick="return followMe('.$newsFeeds["User_ID"].');"><img src="images/ico/10.png"></p>';
     }     
    $currentPostId=$newsFeeds["Post_ID"];  
    $postlikes=$postFeeds->getPostLikesCount($currentPostId);
    $postshares=$postFeeds->getPostShareCount($currentPostId);
    $likesharepost.='<p>'.date("d, M Y",$newsFeeds["Last_Modified_Date"]).'</p>
    			<p onclick="likeMe('.$currentPostId.','.$newsFeeds["Post_Type_ID"].','.$newsFeeds["Parent_ID"].');" >
                    <span style="cursor:pointer">pick</span> 
                    <!--<span style="cursor:pointer"><img src="images/ico/11.png"></span>-->
                    <span id="'.$currentPostId.'_lcount" class="countUpdates">'.$postlikes.'</span>
                </p>
    			<p > <!-- onclick="shareMe('.$currentPostId.','.$newsFeeds["Post_Type_ID"].','.$newsFeeds["Parent_ID"].');" -->
                    <a href="#feed'.$currentPostId.'" class="topopup" onclick="showShareBox('.$currentPostId.','.$newsFeeds["Post_Type_ID"].','.$newsFeeds["Parent_ID"].');" style="cursor:pointer">
                        Share 
                        <!--<span><img src="images/ico/12.png" style="top:6px;"></span>-->
                    </a>
                    <span id="'.$currentPostId.'_scount" class="countUpdates">'.$postshares.'</span>
                </p>
    			<p > <!-- onclick="updatePrivacySettings('.$currentPostId.');" -->
                    <a href="#feed'.$currentPostId.'" onclick="showPrivacyBox('.$currentPostId.','.$newsFeeds["Post_Type_ID"].','.$newsFeeds["Parent_ID"].');" class="button small pop1" data-bpopup=\"{"transition":"slideDown","speed":850,"easing":"easeOutBack"}\" style="cursor:pointer">
                        Privacy
                    </a>
                </p>
                <p >
                    <a href="#feed'.$currentPostId.'" onclick="showPostSettings('.$currentPostId.');" class="button" style="cursor:pointer">
                        Edit Settings
                    </a>
                </p>';
                if($_SESSION["Allyfolio_User_ID"]==$newsFeeds["User_ID"]){
                    $likesharepost.='<p >
                        <a href="#feed'.$currentPostId.'" onclick="showMyPostLocationBox('.$currentPostId.',\''.base64_encode($newsFeeds["post_location"]).'\');" class="button" style="cursor:pointer">
                            Edit Location
                        </a>
                    </p>';      
                }
             
                //echo "<pre>";
//                print_r($postComments);
//                echo "</pre>";
                
    $postlocation="";
    if(strlen(trim($newsFeeds["post_location"]))>0){
        $newsFeeds["post_location"]=getSmileyDataForSave($newsFeeds["post_location"]);
        $postlocation="<div> - <span class='post-location'>".trim($newsFeeds["post_location"])."</span></div>";
        
        $mappath='<div id="mymap-'.$currentPostId.'" style="width: 480px; height: 200px;"></div>
                        <script type="text/javascript">
                            getLatLongForAddress("'.trim($newsFeeds["post_location"]).'","mymap-'.$currentPostId.'");  
                        </script>
                        ';
    }
    else{
        $mappath="";
    }
    $newsFeeds["PostedContent"]=getSmileyDataForSave($newsFeeds["PostedContent"]);
    $feedSection= '<div id="feed'.$currentPostId.'" class="feed">
    <table width="100%" border="0">
    	<tbody>
            <tr>
                    <td width="14%" valign="top"><div class="other_box" style="float:right"><img src="'.$postUserDetail->profilePicPath.'" width=50 style="padding:4px"/></div></td>
                    <td width="71%" valign="top">
                        <p class="box_home_heading">'.$postUserDetail->profileName.$taggingMsgWithPost.$emotionstext.$postlocation.'</p>
                        <p class="box_txt">
                            '.$newsFeeds["PostedContent"].'
                        </p>';
                        
                        $feedSection.="<br/>".$mappath."<br/>";
                        $downloadPrivacyType=$postUserDetail->privacyType["download_pics"];
                        if(is_array($postUploads) && count($postUploads)>0){
                            $videocount=0;
                            foreach($postUploads as $postUpload){
                                $feedSection.='<div class="total">';
                                if($postUpload["Media_Type"]=="IMAGE")
                                {
                                    $fpathencoded=urlencode($postUpload["Media_Path"]);
                                    $feedSection.='<a href="'.$postUpload["Media_Path"].'" data-lightbox="roadtrip'.$currentPostId.'">
                                                    <img src="'.$postUpload["Media_Path"].'" width="500px">';
                                    if($downloadPrivacyType==1){                
                                        $feedSection.='<div><a style="float:right;margin-right:25px" href="downloadpics.php?filepathdownload='.$fpathencoded.'">Download !!</a></div>
                                                    </a>';
                                    }
                                }
                                else
                                {
                                    $feedSection.='
                                    <div id="videouploaded_'.$newsFeeds["Post_ID"].'_'.$videocount.'" style="width:500px;height:350px;"></div>
                                        <script type="text/javascript">
                                            jwplayer("videouploaded_'.$newsFeeds["Post_ID"].'_'.$videocount.'").setup({
                                                "flashplayer": "js/jwplayer.flash.swf",
                                                "file": "'.$postUpload["Media_Path"].'",
                                                "image": "images/dummy_video.jpg",
                                                "controlbar": "bottom",
                                                "width": "500",
                                                "height": "350"
                                            });
                                        </script>
                                    </div>    
                                    ';
                                    $videocount++;
                                }
                                $feedSection.='</div>';
                            }
                        }
                       $feedSection.='<div class="listenMe"><center><img src="images/ico/13.png"></center></div>';
                       $feedSection.='<div class="commentswhite"><form name="multiformCmntUpload'.$currentPostId.'" id="multiformCmntUpload'.$currentPostId.'" action="" method="POST" enctype="multipart/form-data" >';
                       $feedSection.='<div id="'.$currentPostId.'_comments" >';
                       if(is_array($postComments) && count($postComments)>0){
                            for($pccount=0;$pccount<count($postComments);$pccount++){                                
                                $postCommentslist=$postComments[$pccount];
                                $postCommentsUploads=$postFeeds->ReadCommentUploads($newsFeeds["Post_ID"],$postCommentslist["User_Comment_ID"]);
                                $commentUserDetail->getUserDetails($postCommentslist["User_ID"]);
                                $postCommentslist["Post_Comment"]=getSmileyDataForSave($postCommentslist["Post_Comment"]);
                			$feedSection.='<!-- Comment 1 -->
                                <div id="cmnt_row_'.$postCommentslist["User_Comment_ID"].'" class="status2">
                				    <div class="status_top">
                					   <div class="more_pic">
                                           <!--
                    					   <span><img src="images/ico/13.png"></span>
                    					   <span style="margin-top:5px;">000 more...</span>
                    					   <span style="margin-top:5px; margin-left:10px;" >Pick 0</span>
                                           -->
                    					   <div class="clearfix"></div>
                        					<table width="100%" border="0" cellpadding="5" cellspacing="5">
                        					   <tbody>
                                                    <tr>
                        							     <td width="10%" rowspan="2">
                        							         <div class="more_picture"><img src="'.$commentUserDetail->profilePicPath.'" width="40" /></div>
                                                         </td>
                        							     <td width="95%" class="box_home_heading" style="text-shadow:none !important">'.$postCommentslist["Full_Name"].'</td>
                                                         <td width="5%"> <span class="removeCmnt" onclick="deleteMeCmnt('.$currentPostId.','.$postCommentslist["User_Comment_ID"].','.$loggedUserObjlocal->userId.');">X</span> </td>
                        						     </tr>
                        						     <tr>
                        							     <td class="box_txt">
                                                            <span>'.$postCommentslist["Post_Comment"].'</span>
                                                            <span style="margin-left:20px;" onclick="likeComment('.$postCommentslist["User_Comment_ID"].','.$currentPostId.');">Pick <span id="cmt_'.$postCommentslist["User_Comment_ID"].'">0</span></span>
                                                         </td>
                                                         <td></td>
                        						      </tr>
                                                      <tr>
                                                            <td colspan="2" style="padding-left:42px">
                                                            '.manageCommentsUpload($postCommentsUploads,$downloadPrivacyType).'
                                                            </td>
                                                      </tr>
                        					   </tbody>
                                            </table>
                					</div>
                					<div class="clearfix"></div>
                				</div>
                			</div>';
                            
                            }
                        }
                        $feedSection.='</div>';
                        if(is_array($postComments) && count($postComments)>0){
         			        $feedSection.='
                            <div class="com_here">
                                <table width="100%">
                                    <tr>
                                        <td width="50px">
                                            <span><div class="more_picture"><img src="'.$loggedUserObjlocal->profilePicPath.'" width="40" /></div></span>
                                        </td>
                                        <td>
                                            <span>
                                            <div id="'.$currentPostId.'_txtcomment" name="'.$currentPostId.'_txtcomment" class="comment newcommentbox" contenteditable="true" placeholder="Comment here...." onKeyPress="return commentMe('.$currentPostId.',this.id,event);" onblur="return showDefaultText(\'Comment here...\',this.id);" onfocus="return clearDefaultText(\'Comment here...\',this.id);" >
                                                Comment here...
                                                
                                                
                                            </div>'.addCommentUploadSection($currentPostId).'
                            			     <!--<input id="'.$currentPostId.'_txtcomment" name="'.$currentPostId.'_txtcomment" type="text" class="comment" placeholder="Comment here...." onKeyPress="return commentMe('.$currentPostId.',this.value,event);" />-->
                                            </span>
                                            <!--
                                            <span>
                                                <input type="button" id="'.$currentPostId.'_cmdcomment" name="'.$currentPostId.'_cmdcomment" value="comment" onclick="return commentOn('.$currentPostId.');" />
                                            </span>
                                            -->     
                                        </td>
                                    </tr>
                                </table>
                                <div id="'.$currentPostId.'_flist" style="position:absolute;z-index:2000"></div>
                                <div id="'.$currentPostId.'_msgbox" class="tagmsgbox"></div>
                            </div>';
                        }
                        else{
                            $feedSection.='
                            <div style="width: 99.5%;" class="com_here">
                                <table width="100%">
                                    <tr>
                                        <td width="50px">
                                            <span><div class="more_picture"><img src="'.$loggedUserObjlocal->profilePicPath.'" width="40" /></div></span>
                                        </td>
                                        <td>
                                            <span>
                                            <div id="'.$currentPostId.'_txtcomment" name="'.$currentPostId.'_txtcomment" class="comment newcommentbox" contenteditable="true" placeholder="Comment here...." onKeyPress="return commentMe('.$currentPostId.',this.id,event);" onblur="return showDefaultText(\'Comment here...\',this.id);" onfocus="return clearDefaultText(\'Comment here...\',this.id);" >
                                                Comment here...
                                                
                                            </div>'.addCommentUploadSection($currentPostId).'
                            			     <!--<input id="'.$currentPostId.'_txtcomment" name="'.$currentPostId.'_txtcomment" type="text" class="comment" placeholder="Comment here...." onKeyPress="return commentMe('.$currentPostId.',this.value,event);" />-->
                                             </span>
                                             <!--
                                            <span>
                                                <input type="button" id="'.$currentPostId.'_cmdcomment" name="'.$currentPostId.'_cmdcomment" value="comment" onclick="return commentOn('.$currentPostId.');" />
                                            </span>
                                            -->
                                        </td>
                                    </tr>
                                </table>
                                <div id="'.$currentPostId.'_flist" style="position:absolute;z-index:2000"></div>
                                <div id="'.$currentPostId.'_msgbox" class="tagmsgbox"></div>
                            </div>';
                        }
                    $feedSection.='</form></div>';
                       
    $feedSection.= '</td>';
               
    $feedSection.= '<td width="15%" valign="top" class="para">';
                        //show like or share option only if post does not have any uploads
                        $feedSection.=$likesharepost;
    $feedSection.= '</td>';
              
    $feedSection.='
              </tr>         
        </tbody>
    </table>
    <input type="hidden" class="lstfeedtime" value="'.$newsFeeds["Post_ID"].'"/>
</div>';

return $feedSection;

}


function getNewsFeedRight($feedId,$newsFeeds){
    global $relpath;
    //echo "<pre>";
    //    print_r($newsFeeds);
    //echo "</pre>";
    $loggedUserObjlocal=new UserDetails();
    $loggedUserObjlocal->getUserDetails($_SESSION["Allyfolio_User_ID"],true);
    $postUserDetail=new UserDetails();
    $commentUserDetail= new UserDetails();
    $postUserDetail->getUserDetails($newsFeeds["User_ID"]);
    
   
    
    $likesharepost="";
    $postFeeds= new ReadFeedAction();
    $postComments= array();
    $postUploads=array();
    $taggedUsersList=array();
    $taggingMsgWithPost="";
    if($newsFeeds["Post_ID"]!=null && is_numeric(trim($newsFeeds["Post_ID"])) && trim($newsFeeds["Post_ID"])>0){
        $postComments=$postFeeds->ReadPostComments($newsFeeds["Post_ID"]);   
        $postUploads= $postFeeds->ReadPostUploads($newsFeeds["Post_ID"]);
        //$postUploads=(isset($postUploads[0]))?$postUploads[0]:array();
        
        $oDropfilters= new CGetFilters();
        $postReportAbused=array();
        $postReportAbused=$oDropfilters->getPostReportAbuseTypes($_SESSION["Allyfolio_User_ID"],$newsFeeds["Post_ID"]);
        
        if(is_array($postReportAbused) && count($postReportAbused)>0){
            $postReportAbused=$postReportAbused[0];
        }
        //print_r($postReportAbused);    
        $isReportedAbusedOrHidden=false;
        if(is_array($postReportAbused) && isset($postReportAbused["Report_Abuse_IDs"]) && isset($postReportAbused["Status"]) && isset($postReportAbused["Is_Approved_By_Admin"]) ){
            //if report abused and is approved by admin then treat it as approved reported abused
            if($postReportAbused["Is_Approved_By_Admin"]==1 && (strstr($postReportAbused["Report_Abuse_IDs"],",") || is_numeric($postReportAbused["Report_Abuse_IDs"]))){
                $isReportedAbusedOrHidden=true;    
            }
            //or if not approved as reported abused then check if post is hidden (0)
            if($postReportAbused["Status"]==0){
                $isReportedAbusedOrHidden=true;
            }
        }
        if($isReportedAbusedOrHidden)
            return;
            
    }
     if($newsFeeds["Friend_IDs"]!=""){
        if(strstr($newsFeeds["Friend_IDs"],",")){
            $taggedUsersList=explode(",",$newsFeeds["Friend_IDs"]);
        }
        else{
            $taggedUsersList[0]=$newsFeeds["Friend_IDs"];
        }
    }
    
    $emotionstext="";
    if($newsFeeds["postedemotion"]!="" && strlen($newsFeeds["postedemotion"])>0){
        $newsFeeds["postedemotion"]=getSmileyDataForSave($newsFeeds["postedemotion"]);
        $emotionstext="<span class='feel-em'> ".$newsFeeds["postedemotion"]."</span>";
    }
    if(is_array($taggedUsersList) && count($taggedUsersList)){
        $taggingMsgWithPost=' was with {3} <a onclick="showTaggedPersons(\'ptaguser\');"> {1} {2} </a>';
        $inputHidden="<input type='hidden' id='ptaguser' name='ptaguser' value='{1}'/>";
            
        $taggedUsersJson=getTaggedUserDetails($taggedUsersList);
        $oNotification= new Notifications();
        $inputHidden=$oNotification->str_format($inputHidden,$taggedUsersJson);
        $taggingMsgWithPost=$oNotification->str_format($taggingMsgWithPost,count($taggedUsersList),(count($taggedUsersList)>1)?"peoples":"people",$inputHidden);
        //$taggingMsgWithPost=str_format($taggingMsgWithPost,count($taggedUsersList),(count($taggedUsersList)>1)?"peoples":"people",$taggedUsersJson);
    }
    /*
    echo "<pre>user details <br>";
    print_r($postComments);
    echo "</pre>";
    */    
    if($postUserDetail->isCelibrity==true){
        $likesharepost='<!--like/post--> <p onclick="return followMe('.$newsFeeds["User_ID"].');"><img src="images/ico/10.png"></p>';
     }   
    $currentPostId=$newsFeeds["Post_ID"]; 
    
    $postlikes=$postFeeds->getPostLikesCount($currentPostId);
    $postshares=$postFeeds->getPostShareCount($currentPostId);
    $likesharepost.='<p>'.date("d, M Y",$newsFeeds["Last_Modified_Date"]).'</p>
    			<p onclick="likeMe('.$currentPostId.','.$newsFeeds["Post_Type_ID"].','.$newsFeeds["Parent_ID"].');" >
                    <span style="cursor:pointer">pick</span> 
                    <!--<span style="cursor:pointer"><img src="images/ico/11.png"></span>-->
                    <span id="'.$currentPostId.'_lcount" class="countUpdates">'.$postlikes.'</span>
                </p>
    			<p > <!-- onclick="shareMe('.$currentPostId.','.$newsFeeds["Post_Type_ID"].','.$newsFeeds["Parent_ID"].');" -->
                    <a href="#feed'.$currentPostId.'" class="topopup" onclick="showShareBox('.$currentPostId.','.$newsFeeds["Post_Type_ID"].','.$newsFeeds["Parent_ID"].');" style="cursor:pointer">
                        Share 
                        <!--<span><img src="images/ico/12.png" style="top:6px;"></span>-->
                    </a>
                    <span id="'.$currentPostId.'_scount" class="countUpdates">'.$postshares.'</span>
                </p>
    			<p > <!-- onclick="updatePrivacySettings('.$currentPostId.');" -->
                    <a href="#feed'.$currentPostId.'" onclick="showPrivacyBox('.$currentPostId.','.$newsFeeds["Post_Type_ID"].','.$newsFeeds["Parent_ID"].');" class="button small pop1" data-bpopup=\"{"transition":"slideDown","speed":850,"easing":"easeOutBack"}\" style="cursor:pointer">
                        Privacy
                    </a>
                </p>
                <p >
                    <a href="#feed'.$currentPostId.'" onclick="showPostSettings('.$currentPostId.');" class="button" style="cursor:pointer">
                        Edit Settings
                    </a>
                </p>';
                if($_SESSION["Allyfolio_User_ID"]==$newsFeeds["User_ID"]){
                    $likesharepost.='<p >
                        <a href="#feed'.$currentPostId.'" onclick="showMyPostLocationBox('.$currentPostId.',\''.base64_encode($newsFeeds["post_location"]).'\');" class="button" style="cursor:pointer">
                            Edit Location
                        </a>
                    </p>';      
                } 
             
              
    /*$likesharepost.='<p>'.$newsFeeds["Last_Modified_Date"].'</p>
    			<p onclick="likeMe('.$currentPostId.');">pick <span><img src="images/ico/11.png"></span><span class="side">'.$newsFeeds["Total_Likes"].'</span></p>
    			<p onclick="shareMe('.$currentPostId.');">Share <span><img src="images/ico/12.png" style="top:6px;"></span><span class="side">'.$newsFeeds["Total_Shares"].'</span></p>
    			<p onclick="updatePrivacySettings('.$currentPostId.');">Privacy</p>';
      */          
                
    $postlocation="";
    if(strlen(trim($newsFeeds["post_location"]))>0){
        $newsFeeds["post_location"]=getSmileyDataForSave($newsFeeds["post_location"]);
        $postlocation="<p style='text-align:right;padding-right:30px'> - <span class='post-location'>".trim($newsFeeds["post_location"])."</span></p>";
        $mappath='<div id="mymap-'.$currentPostId.'" style="width: 480px; height: 200px;"></div>
                        <script type="text/javascript">
                            getLatLongForAddress("'.trim($newsFeeds["post_location"]).'","mymap-'.$currentPostId.'");  
                        </script>
                        ';
    }
    else{
        $mappath="";
    }
     $newsFeeds["PostedContent"]=getSmileyDataForSave($newsFeeds["PostedContent"]);
    $feedSection= '<div id="feed'.$currentPostId.'" class="feed">
                      <table width="100%" border="0">
		                  <tr>
			                 <td width="15%" valign="top" align="left" class="para">';
                                //show like or share option only if post does not have any uploads
                                $feedSection.=$likesharepost;
               $feedSection.='</td>
			                 <td width="71%" valign="top">
                                <table width="100%">
                                    <tr>
                                        <td>
                                            <p class="box_home_heading" style="float:right;padding-right:10px">'.$postUserDetail->profileName.$taggingMsgWithPost.$emotionstext.'</p>        
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>'.$postlocation.'</td>
                                    </tr>
                                    <tr>
                                    
                                        <td>
                                            <p class="box_txt" style="float:right;padding-right:10px">
                                                '.$newsFeeds["PostedContent"].'
                                            </p>        
                                        </td>
                                    </tr>
                                </table>';
                        $feedSection.="<br/>".$mappath."<br/>";
                        $downloadPrivacyType=$postUserDetail->privacyType["download_pics"];
                        if(is_array($postUploads) && count($postUploads)>0){
                            $videocount=0;
                            foreach($postUploads as $postUpload){
                                $feedSection.='<div class="total">';
                                if($postUpload["Media_Type"]=="IMAGE")
                                {
                                    $fpathencoded=urlencode($postUpload["Media_Path"]);
                                    $feedSection.='<a href="'.$postUpload["Media_Path"].'" data-lightbox="roadtrip'.$currentPostId.'">
                                                    <img src="'.$postUpload["Media_Path"].'" width="500px">';
                                    if($downloadPrivacyType==1){                
                                        $feedSection.='<div><a style="float:right;margin-right:25px" href="downloadpics.php?filepathdownload='.$fpathencoded.'">Download !!</a></div>
                                                    </a>';
                                    }
                                }
                                else
                                {
                                    $feedSection.='
                                    <div id="videouploaded_'.$newsFeeds["Post_ID"].'_'.$videocount.'" style="width:500px;height:350px;"></div>
                                        <script type="text/javascript">
                                            jwplayer("videouploaded_'.$newsFeeds["Post_ID"].'_'.$videocount.'").setup({
                                                "flashplayer": "js/jwplayer.flash.swf",
                                                "file": "'.$postUpload["Media_Path"].'",
                                                "image": "images/dummy_video.jpg",
                                                "controlbar": "bottom",
                                                "width": "500",
                                                "height": "350"
                                            });
                                        </script>
                                    </div>    
                                    ';
                                    $videocount++;
                                }
                                
                                $feedSection.='</div>';
                            }
                        }
                       $feedSection.='<div class="listenMe"><center><img src="images/ico/13.png"></center></div>';
                       $feedSection.='<div class="commentswhite"><form name="multiformCmntUpload'.$currentPostId.'" id="multiformCmntUpload'.$currentPostId.'" action="" method="POST" enctype="multipart/form-data" >';
                       $feedSection.='<div id="'.$currentPostId.'_comments" class="commentswhite">';
                       if(is_array($postComments) && count($postComments)>0){
                            for($pccount=0;$pccount<count($postComments);$pccount++){                                
                                $postCommentslist=$postComments[$pccount];
                                $postCommentsUploads=$postFeeds->ReadCommentUploads($newsFeeds["Post_ID"],$postCommentslist["User_Comment_ID"]);
                                $commentUserDetail->getUserDetails($postCommentslist["User_ID"]);
                                $postCommentslist["Post_Comment"]=getSmileyDataForSave($postCommentslist["Post_Comment"]);
                			$feedSection.='<!-- Comment 1 -->
                                <div id="cmnt_row_'.$postCommentslist["User_Comment_ID"].'" class="status2">
                				    <div class="status_top">
                					   <div class="more_pic">
                    					   <!--
                    					   <span><img src="images/ico/13.png"></span>
                    					   <span style="margin-top:5px;">000 more...</span>
                    					   <span style="margin-top:5px; margin-left:10px;" >Pick 0</span>
                                           -->
                    					   <div class="clearfix"></div>
                        					<table width="100%" border="0" cellpadding="5" cellspacing="5">
                        					   <tbody>
                                                    <tr>
                        							     <td width="10%" rowspan="2">
                        							         <div class="more_picture"><img src="'.$loggedUserObjlocal->profilePicPath.'" width="40" /></div>
                                                         </td>
                        							     <td width="95%" class="box_home_heading" style="text-shadow:none !important">'.$postCommentslist["Full_Name"].'</td>
                                                         <td width="5%"> <span class="removeCmnt" onclick="deleteMeCmnt('.$currentPostId.','.$postCommentslist["User_Comment_ID"].','.$loggedUserObjlocal->userId.');">X</span> </td>
                        						     </tr>
                        						     <tr>
                        							     <td class="box_txt">
                                                            <span>'.$postCommentslist["Post_Comment"].'</span>
                                                            <span style="margin-left:20px;" onclick="likeComment('.$postCommentslist["User_Comment_ID"].','.$currentPostId.');">Pick <span id="cmt_'.$postCommentslist["User_Comment_ID"].'">0</span></span>
                                                         </td>
                                                         <td></td>
                        						      </tr>
                                                      <tr>
                                                            <td colspan="2" style="padding-left:42px">
                                                            '.manageCommentsUpload($postCommentsUploads,$downloadPrivacyType).'
                                                            </td>
                                                      </tr>
                        					   </tbody>
                                            </table>
                					</div>
                					<div class="clearfix"></div>
                				</div>
                			</div>';
                            }   
                        }
                        $feedSection.='</div>';
                        if(is_array($postComments) && count($postComments)>0){
         			        $feedSection.='
                            <div class="com_here">
                                <table width="100%">
                                    <tr>
                                        <td width="50px">
                                            <span><div class="more_picture"><img src="'.$loggedUserObjlocal->profilePicPath.'" width="40" /></div></span>
                                        </td>
                                        <td>
                                            <span>
                                            <div id="'.$currentPostId.'_txtcomment" name="'.$currentPostId.'_txtcomment" class="comment newcommentbox" contenteditable="true" placeholder="Comment here...." onKeyPress="return commentMe('.$currentPostId.',this.id,event);" onblur="return showDefaultText(\'Comment here...\',this.id);" onfocus="return clearDefaultText(\'Comment here...\',this.id);" >
                                            
                                            Comment here...
                                            
                                            </div>'.addCommentUploadSection($currentPostId).'
                            			     <!--<input id="'.$currentPostId.'_txtcomment" name="'.$currentPostId.'_txtcomment" type="text" class="comment" placeholder="Comment here...." onKeyPress="return commentMe('.$currentPostId.',this.value,event);" />-->
                                            </span>
                                            <!--
                                            <span>
                                                <input type="button" id="'.$currentPostId.'_cmdcomment" name="'.$currentPostId.'_cmdcomment" value="comment" onclick="return commentOn('.$currentPostId.');" />
                                            </span>
                                            -->     
                                        </td>
                                    </tr>
                                </table>
                                <div id="'.$currentPostId.'_flist" style="position:absolute;z-index:2000"></div>
                                <div id="'.$currentPostId.'_msgbox" class="tagmsgbox"></div>
                            </div>';
                        }
                        else{
                            $feedSection.='
                            <div style="width: 99.5%;" class="com_here">
                                <table width="100%">
                                    <tr>
                                        <td width="50px">
                                            <span><div class="more_picture"><img src="'.$loggedUserObjlocal->profilePicPath.'" width="40" /></div></span>
                                        </td>
                                        <td>
                                            <span>
                                            <div id="'.$currentPostId.'_txtcomment" name="'.$currentPostId.'_txtcomment" class="comment newcommentbox" contenteditable="true" placeholder="Comment here...." onKeyPress="return commentMe('.$currentPostId.',this.id,event);" onblur="return showDefaultText(\'Comment here...\',this.id);" onfocus="return clearDefaultText(\'Comment here...\',this.id);" >
                                            Comment here...
                                            
                                            </div>'.addCommentUploadSection($currentPostId).'
                            			     <!--<input id="'.$currentPostId.'_txtcomment" name="'.$currentPostId.'_txtcomment" type="text" class="comment" placeholder="Comment here...." onKeyPress="return commentMe('.$currentPostId.',this.value,event);" />-->
                                             </span>
                                             <!--
                                            <span>
                                                <input type="button" id="'.$currentPostId.'_cmdcomment" name="'.$currentPostId.'_cmdcomment" value="comment" onclick="return commentOn('.$currentPostId.');" />
                                            </span>
                                            -->
                                        </td>
                                    </tr>
                                </table>
                                <div id="'.$currentPostId.'_flist" style="position:absolute;z-index:2000"></div>
                                <div id="'.$currentPostId.'_msgbox" class="tagmsgbox"></div>
                            </div>';
                        }
                    $feedSection.='</form></div>';
         			    
                       
    $feedSection.= '</td>';
               
                $feedSection.= '<td width="14%" valign="top" >';
                       $feedSection.= '<div class="other_box" style="float:left"><img src="'.$postUserDetail->profilePicPath.'" width=50 style="padding:4px"/></div>';
                $feedSection.= '</td>';
              
                $feedSection.='
              </tr>         
        </tbody>
    </table>
    <input type="hidden" class="lstfeedtime" value="'.$newsFeeds["Post_ID"].'"/>
</div>';
return $feedSection;
}





?>